
var METADATA_INJECT_KEY = 'METADATA_INJECT_KEY';
import { Token} from './provider';
export function Injector(token) {//是一个参数装饰器工厂,返回是一个参数装饰器
    return function (target, key, paramsIndex) {
        Reflect.defineMetadata(METADATA_INJECT_KEY, token, target, "index-" + paramsIndex);
        return target;
    };
}

export function  getInjectionToken(target, index){
    let token =  Reflect.getMetadata(METADATA_INJECT_KEY, target, "index-" + index);
    return token as  Token<any> | undefined;
}